package com.b511.swpu.cementbackend.repository;

import com.b511.swpu.cementbackend.dto.output.EmployeeManageOutDto;
import com.b511.swpu.cementbackend.entity.SYSM_Employee;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SYSM_EmployeeRepository extends JpaRepository<SYSM_Employee,Long> {

    @Query(value = "select new com.b511.swpu.cementbackend.dto.output.EmployeeManageOutDto(e1.NAME, c1.NAME,u1.UNAME,r1.NAME,e1.EMPGROUP,e1.POSITION) "
            + "from SYSM_Employee e1 " +
            "left join SYSM_Company c1" +
            " on e1.COMPANYCODE=c1.COMPANYCODE" +
            " left join SYSM_user u1" +
            " on e1.EMPLOYEEID=u1.EMPLOYEEID" +
            " left join SYSM_user_role ur1" +
            " on u1.UNAME=ur1.UNAME" +
            " left join SYSM_roles r1" +
            " on ur1.ROLECODE=r1.ROLECODE")
    List<EmployeeManageOutDto> findEmployeeManage();
}
